package com.junjie.services.impl;

import com.junjie.dao.ERInformationDao;
import com.junjie.entity.ERInformation;
import com.junjie.services.ERInformationService;
import com.junjie.utils.CommonParams;
import com.junjie.utils.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ERInformationServiceImpl implements ERInformationService {

    @Autowired
    private ERInformationDao erInformationDao;

    //根据 id 或 e_id 或 r_id 来查询信息
    @Override
    public ERInformation selectERInformationByIdOreIdOrrId(ERInformation erInformation) {
        return erInformationDao.getERInformationByIdOreIdOrrId(erInformation);
    }

    //插入一条员工房间连接信息表
    @Override
    public CommonResult<Integer> insertERInformation(ERInformation erInformation) {
        return new CommonResult<>(CommonParams.SUCCESS, "插入一条信息！", erInformationDao.insertERInformation(erInformation));
    }

    //修改一条数据的方法
    @Override
    public CommonResult<Integer> updateERInformation(ERInformation erInformation) {
        return new CommonResult<>(CommonParams.SUCCESS, "修改数据成功！", erInformationDao.updateAndDeleteERInformation(erInformation));
    }

    //删除一条数据的方法
    @Override
    public CommonResult<Integer> deleteERInformation(Integer id) {
        return new CommonResult<>(CommonParams.SUCCESS, "删除成功！", erInformationDao.deleteERInformation(id));
    }
}
